@ECHO OFF
IF "%VCINSTALLDIR%" == "" GOTO NEED_VS

IF "%1"=="x86" GOTO BUILD_X86
IF "%1"=="X86" GOTO BUILD_X86
IF "%1"=="x64" GOTO BUILD_X64
IF "%1"=="X64" GOTO BUILD_X64

ECHO "Building Exploits x64 and x86 (Release)"
SET PLAT=all
GOTO RUN

:BUILD_X86
ECHO "Building Exploits x86 (Release)"
SET PLAT=x86
GOTO RUN

:BUILD_X64
ECHO "Building Exploits x64 (Release)"
SET PLAT=x64
GOTO RUN

:RUN
ECHO "Building CVE-2010-0232 (KiTrap0D)"
PUSHD CVE-2010-0232
msbuild.exe make.msbuild /target:%PLAT%
POPD

IF "%ERRORLEVEL%"=="0" (
  ECHO "Building CVE-2013-0109 (nvidia_nvsvc)"
  PUSHD CVE-2013-0109
  msbuild.exe make.msbuild /target:%PLAT%
  POPD
)

IF "%ERRORLEVEL%"=="0" (
  ECHO "Building CVE-2013-3660 (ppr_flatten_rec)"
  PUSHD CVE-2013-3660
  msbuild.exe make.msbuild /target:%PLAT%
  POPD
)

IF "%ERRORLEVEL%"=="0" (
  ECHO "Building CVE-2013-3881 (win32k_null_page)"
  PUSHD CVE-2013-3881
  msbuild.exe make.msbuild /target:%PLAT%
  POPD
)

IF "%ERRORLEVEL%"=="0" (
  ECHO "Building CVE-2014-4113 (track_popup_menu)"
  PUSHD CVE-2014-4113
  msbuild.exe make.msbuild /target:%PLAT%
  POPD
)

IF "%ERRORLEVEL%"=="0" (
  ECHO "Building CVE-2015-1701 (copy_client_image)"
  PUSHD CVE-2015-1701
  msbuild.exe make.msbuild /target:%PLAT%
  POPD
)

IF "%ERRORLEVEL%"=="0" (
  ECHO "Building CVE-2013-1300 (schlamperei)"
  PUSHD CVE-2013-1300
  msbuild.exe make.msbuild /target:%PLAT%
  POPD
)

IF "%ERRORLEVEL%"=="0" (
  ECHO "Building bypassuac (on-disk)"
  PUSHD bypassuac
  msbuild.exe make.msbuild /target:%PLAT%
  POPD

)

IF "%ERRORLEVEL%"=="0" (
  ECHO "Building bypassuac (in-memory)"
  PUSHD bypassuac_injection
  msbuild.exe make.msbuild /target:%PLAT%
  POPD
)

)

IF "%ERRORLEVEL%"=="0" (
  ECHO "Building IE11 Sandbox bypasses"
  PUSHD IE11SandboxEscapes
  msbuild.exe make.msbuild /target:%PLAT%
  POPD
)

IF "%ERRORLEVEL%"=="0" (
  ECHO "Building CAPCOM.SYS Driver exec"
  PUSHD capcom_sys_exec
  msbuild.exe make.msbuild /target:%PLAT%
  POPD
)

FOR /F "usebackq tokens=1,2 delims==" %%i IN (`wmic os get LocalDateTime /VALUE 2^>NUL`) DO IF '.%%i.'=='.LocalDateTime.' SET LDT=%%j
SET LDT=%LDT:~0,4%-%LDT:~4,2%-%LDT:~6,2% %LDT:~8,2%:%LDT:~10,2%:%LDT:~12,6%
echo Finished %ldt%

GOTO :END

:NEED_VS
ECHO "This command must be executed from within a Visual Studio Command prompt."
ECHO "This can be found under Microsoft Visual Studio 2013 -> Visual Studio Tools"

:END
